<template>
  <div class="login-container animate__animated animate__fadeIn">
    <div class="banner">
      <div class="cover"></div>
      <div class="imgBox">
        <img
          :class="{
            first: true,
            firstChange: imgChange,
          }"
          src="../../assets/image/bg2.jpg"
        />
        <img
          :class="{
            second: true,
            secondChange: imgChange,
          }"
          src="../../assets/image/bg1.jpg"
        />
      </div>
      <div class="goHome" @click="router.push('/')">
        <i class="fa fa-angle-left"></i><span>返回</span>
      </div>
      <div class="contentBox">
        <div class="changeBox">
          <span :class="{ Active: !imgChange }" @click="imgChange = !imgChange"
            >登录</span
          >
          <el-switch
            v-model="imgChange"
            :width="50"
            style="margin: 0 10px"
            active-color="#147e68bd"
            inactive-color="#5a096abd"
          />
          <span :class="{ Active: imgChange }" @click="imgChange = !imgChange"
            >注册</span
          >
        </div>
        <div class="loginBox">
          <login-content :imgChange="!imgChange"></login-content>
          <register-content :imgChange="!imgChange"></register-content>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from "vue";
import { useRouter } from "vue-router";
import loginContent from "./components/loginContent";
import registerContent from "./components/registerContent";
const router = useRouter();
let imgChange = ref(false);
</script>

<style scoped lang="less">
.banner {
  position: relative;
  width: 100vw;
  height: 100vh;
  color: #fff;
  .imgBox {
    width: 100%;
    height: 100%;
    position: relative;
    overflow-x: hidden;
    .first {
      left: 0;
      transition: all 0.7s;
    }
    .firstChange {
      left: calc(-100vw);
    }
    .second {
      transition: all 0.7s;
      left: calc(100vw);
    }
    .secondChange {
      left: 0;
    }
    img {
      position: absolute;
      width: 100%;
      height: 100%;
    }
  }

  .cover {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background-color: rgba(0, 0, 0, 0.2);
    z-index: 10;
  }
  .goHome {
    cursor: pointer;
    width: 100px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 1%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 999;
    color: rgb(238, 221, 221);
    animation: arrowmove 3s infinite;
    font-size: 25px;
    i {
      font-size: 35px;
      margin-right: 10px;
    }
  }
  @keyframes arrowmove {
    0% {
      opacity: 1;
    }
    100% {
      left: 48%;
      opacity: 0;
    }
  }
  .contentBox {
    position: absolute;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    top: 50%;
    left: 50%;
    transform: translateX(-50%) translateY(-50%);
    width: 350px;
    height: 500px;
    z-index: 999;
    perspective: 1000px;
    .changeBox {
      display: flex;
      justify-content: center;
      align-items: center;
      span {
        font-size: 20px;
        transition: 0.7s;
        letter-spacing: 5px;
        cursor: pointer;
      }
      .Active {
        font-size: 25px;
        font-weight: 700;
        color: #b8e6f6;
      }
    }
  }
  .loginBox {
    position: relative;
    width: 350px;
    height: 450px;
    perspective: 800px;
    transition: 0.5s;
  }
  .loginBox:hover {
    transform: scale(1.05);
  }
}
</style>
